# -*- coding: utf-8 -*-
# banma-
# PyCharm
# 2023/8/25
# 15:35

import pytest
import os
from commonon.read_data import data
from commonon.read_data import write

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# 获取yaml文件中的参数
def get_data(yaml_file_name):
    try:
        data_file_path = os.path.join(BASE_PATH, "data", yaml_file_name)
        yaml_data = data.load_yaml(data_file_path)
    except Exception as ex:
        pytest.skip(str(ex))
    else:
        return yaml_data

# 将参数写入到txt文件中
def write_txt_file(txt_file_name, str_demo):
    try:
        data_file_path = os.path.join(BASE_PATH, "data", txt_file_name)
        new_write = write.write_txt(data_file_path, str_demo)
    except Exception as ex:
        pytest.skip(str(ex))

# 将txt文件参数读取出来
def read_txt_file(txt_file_name):
    try:
        data_file_path = os.path.join(BASE_PATH, "data", txt_file_name)
        new_read = data.load_txt(data_file_path)
    except Exception as ex:
        pytest.skip(str(ex))
    else:
        return new_read

if __name__ == '__main__':
    print(get_data("select_all_books_data.yaml")["test001"])